package com.example.contrl;


import com.example.pojo.Result;
import com.example.pojo.UserPass;
import com.example.service.LoginService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
public class Login {
    @Autowired
    private LoginService loginService;
    @PostMapping("/login")
    public Result login(@RequestBody UserPass userPass){
        log.info("登录 {}",userPass);
         UserPass userPass1=loginService.login(userPass);
        if(userPass1!=null){
            return Result.success(userPass1);
        }
        return Result.error("ERROR_LOGIN");
    }

    @PostMapping ("/UpdatePassWord")
    public Result updatePasswd(@RequestBody UserPass userPass){
        log.info("修改密码{}",userPass);
        loginService.updatePassWord(userPass);
        return Result.success();
    }
}
